﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Contact : System.Web.UI.Page
{
    private SqlCommand CMD;
    private DataTable TB;
    private DataSet DS;
    private SqlConnection CON;
    private SqlDataAdapter DA;
    protected void Page_Load(object sender, EventArgs e)
    {
        TB = new DataTable();
        string connectString = WebConfigurationManager.ConnectionStrings["connect"].ConnectionString;
        CON = new SqlConnection(connectString);
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (CON.State == ConnectionState.Open)
                CON.Close();
            else
                CON.Open();
            CMD = new SqlCommand("spAddNewFeedBack", CON);
            CMD.CommandType = CommandType.StoredProcedure;
            CMD.Parameters.Add("@content", SqlDbType.NVarChar).Value = TextBox1.Text;
            CMD.ExecuteNonQuery();
            //upload image on server
            Response.Redirect("ThanksFB.aspx");
        }
        catch (SqlException ex)
        {
            throw new Exception(ex.Message);
        }
        finally
        {
            CON.Close();
        }
    }
}